package com.carpedil.movie.controller;

import com.carpedil.common.dto.MovieDTO;
import com.carpedil.movie.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/** @author Administrator */
@Controller
@RequestMapping("/movie")
public class MovieController {
  @Autowired MovieService movieService;

  @GetMapping("/find/{movieId}")
  @ResponseBody
  public MovieDTO findMovieById(@PathVariable("movieId") Integer movieId) {
    return movieService.findMovieById(movieId);
  }

  @GetMapping("/list")
  @ResponseBody
  public List<MovieDTO> getAllMovie() {
    System.out.println("MovieController.getAllMovie>>>>>>>>>>>");
    return movieService.getAllMovie();
  }

  @GetMapping({"/", "/index"})
  public String toIndex() {
    return "index";
  }
}
